function init(title){
	var title=$(document).attr("title");
	$.ajax({
		type:"POST",
		url:"/SmartCommunity/pc/authority_menu",
		//contentType:"application/json;charset=utf-8",
		success:function(data){
			alert(data);
			var arr1=eval("("+data+")");
			var arr=arr1.button;
			for(var i=0;i<arr.length;i++){
				if(arr[i].subButton!=""){
					if(arr[i].name==title){
						$(".navbar-nav").append("<li class=\"dropdown active\" ><a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-haspopup=\"true\" aria-expanded=\"false\">"+arr[i].name+"<span class=\"caret\"></span></a><ul class=\"dropdown-menu\">");
					}else{
						$(".navbar-nav").append("<li class=\"dropdown\" ><a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-haspopup=\"true\" aria-expanded=\"false\">"+arr[i].name+"<span class=\"caret\"></span></a><ul class=\"dropdown-menu\">");							
					}
					for(var j=0;j<arr[i].subButton.length;j++){
						$(".dropdown-menu").append("<li><a href=\'"+arr[i].subButton[j].url+"\'>"+arr[i].subButton[j].name+"</a></li>");
					}
				}
				else if(arr[i].type=="red"){
					$.ajax({
						type : "POST",
						async : false,
						url : "/SmartCommunity/pc/if_exists_unhandled_repair_request",
						contentType : "application/json;charset=utf-8",
						success : function(data) {
							if(data=="true"){
								if(arr[i].name==title){
									$(".navbar-nav").append("<li><a class=\"active\" href=\'"+arr[i].url+"\'>"+arr[i].name+"<span class=\"W_new_count\" style=\"display:inline-block;\">.</span></a></li>");					
								}else{
									$(".navbar-nav").append("<li><a href=\'"+arr[i].url+"\'>"+arr[i].name+"<span class=\"W_new_count\" style=\"display:inline-block;\">.</span></a></li>");							
								}
							}
							else{
								if(arr[i].name==title){
									$(".navbar-nav").append("<li><a class=\"active\" href=\'"+arr[i].url+"\'>"+arr[i].name+"</a><span class=\"W_new_count\" style=\"display:none;\">.</span></li>");					
								}else{
									$(".navbar-nav").append("<li><a href=\'"+arr[i].url+"\'>"+arr[i].name+"</a><span class=\"W_new_count\" style=\"display:none;\">.</span></li>");							
								}
							}
						},
						error : function() {
							alert("error");
						}
					});
				}
				else{
					if(arr[i].name==title){
						$(".navbar-nav").append("<li><a class=\"active\" href=\'"+arr[i].url+"\'>"+arr[i].name+"</a></li>");							
					}else{
						$(".navbar-nav").append("<li><a href=\'"+arr[i].url+"\'>"+arr[i].name+"</a></li>");
					}
				}
			}
			
		},
		error:function(){
			alert("error");
			}
	});
	
		
		var socket = $.atmosphere;
		handleAtmosphere("websocket");
		function handleAtmosphere(transport) {
			var request = new $.atmosphere.AtmosphereRequest();
			request.transport = transport;
			request.url = "/SmartCommunity/pc/user-notifications/repair";
			request.contentType = "application/json";
			request.fallbackTransport = 'long-polling';
			request.onMessage = function(response) {
				if($(".W_new_count").css("display")=="none"){
					$(".W_new_count").css("display", "inline");
					alert("dot1");
				}
			};
			request.onMessagePublished = function(response) {
			};
			request.onOpen = function() {
				$.atmosphere.log('info', [ 'socket open' ]);
			};
			request.onError = function() {
				$.atmosphere.log('info', [ 'socket error' ]);
			};
			request.onReconnect = function() {
				$.atmosphere.log('info', [ 'socket reconnect' ]);
			};
			var subSocket = socket.subscribe(request);
		}
		$("#quit")
				.click(
						function() {
							if (confirm("你确定要退出系统吗？")) {
								$
										.ajax({
											type : "POST",
											url : "/SmartCommunity/pc/logout",
											contentType : "application/json;charset=utf-8",
											success : function(data) {
												if (data == "true") {
													window.location.href = "/SmartCommunity/views/pc/login.html";
												} else {
													alert("退出系统失败");
												}
											},
											error : function() {
												alert("error");
											}
										});
							}
						});
}